package com.suning.sawp.dto.mainpush;

import java.io.Serializable;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.apache.commons.collections.CollectionUtils;

import com.suning.nsfuaa.employee.dto.Employee;
import com.suning.nsfuaa.roleauth.dto.EmpLoginExt;
import com.suning.sawp.constants.ClerkConstants;
import com.suning.sawp.dto.storeman.Category;
import com.suning.vgs.follow.remote.store.StoreManBaseDto;

public class StoreManDto implements Serializable {

    /**
     */
    private static final long serialVersionUID = -3187054120829549566L;

    /**
     * 店员工号
     */
    private String staffId;

    /**
     * 店员姓名
     */
    private String staffName;

    /**
     * 门店编码
     */
    private String storeCode;

    /**
     * 门店名称
     */
    private String storeName;

    /**
     * 门店级别
     */
    private String storeLevel;
    
    /**
     * 门店类型编码
     */
    private String storeTypeCode;
    
    /**
     * 门店类型名称
     */
    private String storeTypeName;
    
    /**
     * 财务分公司编码
     */
    private String branchCode;

    /**
     * 财务分公司名称
     */
    private String branchName;

    /**
     * 组织分公司编码
     */
    private String orgBranchCode;
    
    /**
     * 岗位编码
     */
    private String positionId;

    /**
     * 岗位名称
     */
    private String positionName;

    /**
     * 大区编码
     */
    private String regionCode;
    
    /**
     * 财务大区编码
     */
    private String saleRegionCode;

    /**
     * 大区名称
     */
    private String regionName;
    
    /**
     * LES 3位城市编码   025
     */
    private String cityCode;
    
    /**
     * 区域编码  0250503
     */
    private String areaCode;

    /**
     * 私人手机号
     */
    private String personalMobile;
    
    /**
     * 公司号
     */
    private String companyMobile;
    
    /**
     * 品类信息
     */
    private List<Category> categories;

    /**
     * 组织层级编码 0总部层级 1分公司层级 2大区层级 4门店层级 3其他
     */
    private String orgLevelCode;
    
    public StoreManDto() {

    }

    public StoreManDto(StoreManBaseDto storeManBaseDto, Employee employee, List<Category> categories,EmpLoginExt empLoginExt) {
        this.staffId = employee.getEmployeeId();
        this.staffName = employee.getEmployeeName();
        this.storeCode = empLoginExt.getOrgCode();
        this.orgLevelCode = empLoginExt.getOrgLevelCode();
        this.storeName = empLoginExt.getOrgDisplayName();
        if (ClerkConstants.DEPUTY_STORE_KEEPER.equals(empLoginExt.getPostionId())) {
            // 副店长，等同于店长处理
            this.positionId = ClerkConstants.STORE_KEEPER;
        } else {
            this.positionId = empLoginExt.getPostionId();
        }
        this.positionName = empLoginExt.getPostionName();
        this.branchCode = empLoginExt.getCompanyCode();
        this.branchName = empLoginExt.getCompanyName();
        //5位
        this.regionCode = empLoginExt.getDistinctId();
        this.regionName = empLoginExt.getDistinctName();
        this.companyMobile = employee.getCompanyCellphone();
        this.personalMobile = employee.getPersonalCellphone();

        if (CollectionUtils.isNotEmpty(categories)) {
            this.categories = categories;
        }
    }
    

    public String getStaffId() {
        return staffId;
    }

    public void setStaffId(String staffId) {
        this.staffId = staffId;
    }

    public String getStaffName() {
        return staffName;
    }

    public void setStaffName(String staffName) {
        this.staffName = staffName;
    }

    public String getStoreCode() {
        return storeCode;
    }

    public void setStoreCode(String storeCode) {
        this.storeCode = storeCode;
    }

    public String getPositionId() {
        return positionId;
    }

    public void setPositionId(String positionId) {
        this.positionId = positionId;
    }

    public String getPositionName() {
        return positionName;
    }

    public void setPositionName(String positionName) {
        this.positionName = positionName;
    }

    public List<Category> getCategories() {
        return categories;
    }

    public void setCategories(List<Category> categories) {
        this.categories = categories;
    }

    public String getRegionCode() {
        return regionCode;
    }

    public void setRegionCode(String regionCode) {
        this.regionCode = regionCode;
    }

    public String getRegionName() {
        return regionName;
    }

    public void setRegionName(String regionName) {
        this.regionName = regionName;
    }

    public String getStoreName() {
        return storeName;
    }

    public void setStoreName(String storeName) {
        this.storeName = storeName;
    }

    public String getBranchCode() {
        return branchCode;
    }

    public void setBranchCode(String branchCode) {
        this.branchCode = branchCode;
    }

    public String getBranchName() {
        return branchName;
    }

    public void setBranchName(String branchName) {
        this.branchName = branchName;
    }

    public String getStoreLevel() {
        return storeLevel;
    }

    public void setStoreLevel(String storeLevel) {
        this.storeLevel = storeLevel;
    }

    public String getPersonalMobile() {
        return personalMobile;
    }

    public void setPersonalMobile(String personalMobile) {
        this.personalMobile = personalMobile;
    }

    public String getCompanyMobile() {
        return companyMobile;
    }

    public void setCompanyMobile(String companyMobile) {
        this.companyMobile = companyMobile;
    }

    public String getOrgBranchCode() {
        return orgBranchCode;
    }

    public void setOrgBranchCode(String orgBranchCode) {
        this.orgBranchCode = orgBranchCode;
    }

    public String getSaleRegionCode() {
        return saleRegionCode;
    }

    public void setSaleRegionCode(String saleRegionCode) {
        this.saleRegionCode = saleRegionCode;
    }

    public String getStoreTypeCode() {
        return storeTypeCode;
    }

    public void setStoreTypeCode(String storeTypeCode) {
        this.storeTypeCode = storeTypeCode;
    }

    public String getStoreTypeName() {
        return storeTypeName;
    }

    public void setStoreTypeName(String storeTypeName) {
        this.storeTypeName = storeTypeName;
    }

    public String getCityCode() {
        return cityCode;
    }

    public void setCityCode(String cityCode) {
        this.cityCode = cityCode;
    }

    public String getAreaCode() {
        return areaCode;
    }

    public void setAreaCode(String areaCode) {
        this.areaCode = areaCode;
    }

    public String getOrgLevelCode() {
        return orgLevelCode;
    }

    public void setOrgLevelCode(String orgLevelCode) {
        this.orgLevelCode = orgLevelCode;
    }

    /**
     * 
     * 功能描述: 校验品类编码是否归属于此工号<br>
     * 〈功能详细描述〉
     *
     * @param cateCode
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    public boolean validHasCate(String cateCode) {
        if (CollectionUtils.isNotEmpty(categories)) {
            Set<String> cateCodes = new HashSet<String>();
            for (Category category : categories) {
                cateCodes.add(category.getCategoryCode());
            }
            return cateCodes.contains(cateCode);
        } else {
            return false;
        }
    }

    @Override
    public String toString() {
        return "StoreManDto [staffId=" + staffId + ", staffName=" + staffName + ", storeCode=" + storeCode
                + ", storeName=" + storeName + ", storeLevel=" + storeLevel + ", storeTypeCode=" + storeTypeCode
                + ", storeTypeName=" + storeTypeName + ", branchCode=" + branchCode + ", branchName=" + branchName
                + ", orgBranchCode=" + orgBranchCode + ", positionId=" + positionId + ", positionName=" + positionName
                + ", regionCode=" + regionCode + ", saleRegionCode=" + saleRegionCode + ", regionName=" + regionName
                + ", cityCode=" + cityCode + ", areaCode=" + areaCode + ", personalMobile=" + personalMobile
                + ", companyMobile=" + companyMobile + ", categories=" + categories + ", orgLevelCode=" + orgLevelCode
                + "]";
    }
    
}
